package com.itheima.train.manager.order.handler.configuration;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;

/**
 * @program: itheima-train-manager-parent
 * @description: 配置rabbitmq相关的队列, 交换机, 和绑定关系
 * @author: zhanghz001
 * @create: 2021-07-08 09:43
 **/
// @Configuration
public class ZhzRabbitmqConfiguration {
    
    @Bean("delete_sorted_from_redis")
    public Queue deleteSortedFromRedis() {
        return QueueBuilder.durable("delete_sorted_from_redis").build();
    }
    
    @Bean("train_manager_ex")
    public Exchange trainManagerEx() {
        return ExchangeBuilder.directExchange("train_manager_ex").build();
    }
    
    @Bean
    public Binding deleteSortedFromRedisBindingExchange(
            @Qualifier(value = "train_manager_ex") Exchange exchange,
            @Qualifier(value = "delete_sorted_from_redis") Queue queue) {
        
        return BindingBuilder.bind(queue).to(exchange)
                .with("delete_sorted").noargs();
    }
}
